package jmine.tec.aom;

import java.util.Set;

import jmine.tec.aom.dao.PropertyDAO;
import jmine.tec.aom.domain.AbstractPropertyValue;
import jmine.tec.aom.domain.Propertized;
import jmine.tec.aom.domain.Property;
import jmine.tec.aom.util.FullPropertyHandler;
import jmine.tec.aom.util.PropertyValueUtils;
import bancosys.tec.persist.controller.AbstractPersistenceEnabledController;

/**
 * Controller for the AOM component.
 * 
 * @author jrenaut
 */
public class AOMController extends AbstractPersistenceEnabledController {

    private PropertyValueUtils propertyValueUtils;

    private PropertyDAO propertyDAO;

    /**
     * @return the propertyValueUtils
     */
    public PropertyValueUtils getPropertyValueUtils() {
        return this.propertyValueUtils;
    }

    /**
     * @param propertyValueUtils the propertyValueUtils to set
     */
    public void setPropertyValueUtils(PropertyValueUtils propertyValueUtils) {
        this.propertyValueUtils = propertyValueUtils;
    }

    /**
     * @param propertyDAO the propertyDAO to set
     */
    public void setPropertyDAO(PropertyDAO propertyDAO) {
        this.propertyDAO = propertyDAO;
    }

    /**
     * @param target the {@link Propertized} to be handled
     * @param dynamicProperties the dynamic {@link Property} to be aware of
     * @param dynamicPropertyValues the {@link AbstractPropertyValue} to be aware of
     * @return a {@link Propertized} that will handle the operations
     */
    public Propertized createPropertyHandler(Propertized target, Set<Property> dynamicProperties,
            Set<AbstractPropertyValue<?>> dynamicPropertyValues) {
        return new FullPropertyHandler(this.propertyValueUtils, this.propertyDAO, target, dynamicProperties, dynamicPropertyValues);
    }

    /**
     * @param target the {@link Propertized} to be handled
     * @param parent the parent {@link Propertized}
     * @param dynamicPropertyValues the {@link AbstractPropertyValue} to be aware of
     * @return a {@link Propertized} that will handle the operations
     */
    public Propertized createPropertyHandler(Propertized target, Propertized parent, Set<AbstractPropertyValue<?>> dynamicPropertyValues) {
        return new FullPropertyHandler(this.propertyValueUtils, this.propertyDAO, target, parent, dynamicPropertyValues);
    }

}
